package round86;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

/**
 * User: Samuel
 * Date: 09-08-11
 * Time: 09:08 AM
 */
public class A {
    public static void main(String[] args) throws IOException {
        BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
        long num = Long.parseLong(in.readLine());
        long power = Long.parseLong(in.readLine());
        long pow = num;
        int n = 0;
        while ( pow <= 1L<<31) {
            if (pow == power) {
                System.out.println("YES");
                System.out.println(n);
                System.exit(0);
            }
            pow *= num;
            n++;
        }
        System.out.println("NO");
    }
}
